home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Classes 1.2 / RadioButton / LAGARadioButton.h < prev   
Text File  |  1996-06-30  |  7KB  |  139 lines

  1. // ===========================================================================
  2. //    LAGARadioButton.h
  3. // ===========================================================================
  4. //    “Apple Grayscale Appearance” compliant Radio Button
  5. //    Copyright © 1996 Chrisoft (Christophe ANDRES)  All rights reserved.
  6. //
  7. //    You may use this source code in any application (commercial, shareware, freeware,
  8. //    postcardware, etc), but not remove this notice (no need to acknowledge the use of
  9. //    this class in the about box)
  10. //    You may not sell this source code in any form. This source code may be placed on 
  11. //    publicly accessable archive sites and source code disks. It may not be placed on 
  12. //    profit archive sites and source code disks without the permission of the author, 
  13. //    Christophe ANDRES.
  14. //    
  15. //        This source code is distributed in the hope that it will be useful,
  16. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. //
  19. //    If you make any change or improvement on this class, please send the improved/changed
  20. //    version to : chrisoft@calva.net or Christophe ANDRES
  21. //                                     20, rue Prosper Mérimée
  22. //                                     67100 STRASBOURG
  23. //                                     FRANCE
  24. //
  25. // ===========================================================================
  26. //    LAGARadioButton.cp            <- double-click + Command-D to see class implementation
  27. //
  28. //    LAGARadioButton is my implementation of the “Apple Grayscale Appearance for System 7.5”
  29. //        Radio Buttons
  30. //
  31. //        This class requires AGAColors.cp to be present in your project
  32. //
  33. //        Version : 1.2
  34. //
  35. //        Change History (most recent first, date in US form : mm/dd/yy):
  36. //
  37. //                        06/30/96    ca        Public release of version 1.2
  38. //                        06/28/96    ca        Added DisableSelf and EnableSelf methods
  39. //                        06/04/96    ca        made CW9 adjustments
  40. //                                                        Added guard macros in header files
  41. //                                                        Increased version to 1.2
  42. //                        05/25/96    ca        Relinquish memory used by the static PixMapHandle if no radio button is used anymore
  43. //                        05/23/96    ca        Updated the below changes (M™H) to allow the usage of either the standard radio button template
  44. //                                                            or the custom LAGARadioButton template. The standard radio button template is easier for layout
  45. //                                                            because you can see the text, but you cannot define directly a mixed value radio button
  46. //                                                        Defined class_ID1 and CreateAGARadioButtonStream1 to handle the two template possibilities
  47. //                                                        Added a CPPb to "LAGARadioButton CPPb.rsrc" called LAGARadioButton1 to handle the standard
  48. //                                                            radio button template, without having to tinker the class ID
  49. //                                                        Added a static RegisterClass method to simplify the class registration
  50. //                        05/23/96    M™H        Changed the stream constructor to use the standard radio button template in Contructor
  51. //                                                            which enables to see the text put in a radio button while defining the view
  52. //                        05/16/96    ca        Increased version to 1.1
  53. //                                                        Added copy constructor
  54. //                                                        Added "on the fly" constructor
  55. //                                                        Added GetDescriptor and SetDescriptor
  56. //                                                        Added SetTextTraitsID and GetTextTraitsID
  57. //                                                        Added change history
  58. //                        05/15/96    M™H        changes proposed by Michael(tm) Hamel <mhamel@adi.co.nz>    (Thanks a lot ;)
  59. //                                                        use a static PixMapHandle for FASTER draw of the button (uses less code too)
  60. //                                                        Note : the previous drawing method is available conditionnaly by defining SLOW_AGA_RADIO_DRAW
  61. //                                                                        which uses more code, but less data (we never know who could need this ;)
  62. //                                                                        To compare speed, with M™H's method, drawing 135 radio buttons on a 9500/120
  63. //                                                                        takes around 0s20 and with the SLOW_AGA_RADIO_DRAW method, the same takes around 1s70
  64. //                        04/22/96    ca        class made available by Christophe ANDRES <chrisoft@calva.net>
  65. //                                                        (version 1.0)
  66. //
  67. //        To Do:
  68. //
  69.  
  70. #ifndef _H_LAGARadioButton
  71. #define _H_LAGARadioButton
  72. #pragma once
  73.  
  74. #undef SLOW_AGA_RADIO_DRAW                //    define this symbol to use the “slow” drawing method (more code, but less data generated)
  75. #define AGA_USE_STD_RADIOCPPB            //    undefine this symbol to use the 1.0 CPPb instead of the standard Radio button PPob definition
  76.  
  77. #include <LControl.h>
  78. #include <LString.h>
  79.  
  80. class    LAGARadioButton : public LControl
  81. {
  82.     public        :
  83.         enum { class_ID = 'AGA2', class_ID1 = 'AgA2' };                                                                                                            //    begin <05/23/96 ca>
  84.         static void RegisterClass ();
  85.         static LAGARadioButton* CreateAGARadioButtonStream (LStream *inStream);
  86.         static LAGARadioButton* CreateAGARadioButtonStream1 (LStream *inStream);                                                        //    end <05/23/96 ca>
  87.     
  88.         LAGARadioButton ();
  89.         
  90.         LAGARadioButton (LStream *inStream, Boolean inCreateWithRadioButton = false);                                             //    <05/23/96 ca>
  91.         
  92.         LAGARadioButton (const LAGARadioButton &inOriginal);                                                                                                //    <05/16/96 ca>
  93.         
  94.         LAGARadioButton (const SPaneInfo &inPaneInfo, MessageT inValueMessage, Int32 inValue,                             //    <05/16/96 ca>
  95.                                             ResIDT inTextTraitsID,Str255 inTitle);
  96.                                     
  97.         virtual ~LAGARadioButton ();
  98.  
  99.         virtual void SetValue (Int32 inValue);
  100.     
  101.         virtual StringPtr GetDescriptor (Str255 outDescriptor) const;                                                                                //    <05/16/96    ca>
  102.         
  103.         virtual void SetDescriptor (ConstStringPtr inDescriptor);                                                                                        //    <05/16/96    ca>
  104.         
  105.         virtual void SetTextTraitsID (ResIDT inTextTraitsID) { mTextTraitsID = inTextTraitsID; Refresh(); };//    <05/16/96    ca>
  106.         
  107.         virtual ResIDT GetTextTraitsID () { return(mTextTraitsID); };                                                                                //    <05/16/96    ca>
  108.         
  109.     protected    :
  110.         virtual void DrawSelf ();
  111.         
  112.         virtual void DrawGraphic (Boolean inPushed = false);
  113.         
  114.         virtual void DrawText ();
  115.         
  116.         virtual void HotSpotAction (Int16 inHotSpot, Boolean inCurrInside, Boolean inPrevInside);
  117.         
  118.         virtual void HotSpotResult (Int16 inHotSpot);
  119.     
  120.         virtual void DisableSelf () { Refresh(); };                                                                                                                    //    <06/28/96    ca>
  121.  
  122.         virtual void EnableSelf () { Refresh(); };                                                                                                                    //    <06/28/96    ca>
  123.  
  124.         LStr255 mTitle;
  125.         ResIDT mTextTraitsID;
  126.  
  127. #ifndef SLOW_AGA_RADIO_DRAW
  128.     private        :
  129.         static void Initialise();                                                                                                                                                        //    <05/15/96    M™H>
  130.         
  131.         static char mDraw[9][12][12];
  132.         static PixMapHandle mImages;                                                                                                                                                //    <05/15/96    M™H>
  133.         static RgnHandle mRadioClip;                                                                                                                                                //    <05/15/96    M™H>
  134.         static long mUsage;                                                                                                                                                                    //    <05/25/96 ca>
  135. #endif /*!SLOW_AGA_RADIO_DRAW*/
  136. };
  137.  
  138. #endif
  139.